export function exportExcel(res, data) {
  const resData = `\ufeff${res}`;
  const fileName = `${data.dataTable}_${data.apiCode}_tableData`;
  const blob = new Blob([resData]);

  // IE11
  if (window.navigator && window.navigator.msSaveOrOpenBlob) {
    window.navigator.msSaveOrOpenBlob(blob, fileName);
  } else {
    const fileUrl = window.URL.createObjectURL(blob);
    let link = document.createElement('a');
    link.href = fileUrl;
    link.download = `${fileName}.csv`;
    link.click();
    link = null;
    window.URL.revokeObjectURL(fileUrl);
    document.body.removeChild(link);
  }
}
